package com.spsoft.vatoutinv.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 旅客运输-交通运输工具类型枚举类
 *
 * @author : chenxudong
 * @date : 2024/2/5 11:08
 */
@Getter
public enum JtysgjlxEnum {

    AIR_PLANE("1", "飞机", new String[]{"公务舱", "头等舱", "经济舱"}),
    TRAIN("2", "火车", new String[]{"一等座", "二等座", "软席（软座、软卧）", "硬席（硬座、硬卧）"}),
    COACH("3", "长途汽车"),
    BUS("4", "公共交通"),
    TAXI("5", "出租车"),
    CAR("6", "汽车"),
    SHIP("7", "船舶", new String[]{"一等舱", "二等舱", "三等舱"}),
    OTHER("9", "其他");

    private final String code;
    private final String name;
    private String[] zwdj; //座位等级

    JtysgjlxEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    JtysgjlxEnum(String code, String name, String[] zwdj) {
        this.code = code;
        this.name = name;
        this.zwdj = zwdj;
    }

    public static JtysgjlxEnum getInstanceCode(String code) {
        if (code == null) {
            return null;
        }
        return Arrays.stream(JtysgjlxEnum.values()).filter(e-> e.getCode().equals(code)).findFirst().orElse(null);
    }

    public static JtysgjlxEnum getInstanceName(String name) {
        if (name == null) {
            return null;
        }
        return Arrays.stream(JtysgjlxEnum.values()).filter(e-> e.getName().equals(name)).findFirst().orElse(null);
    }
}
